package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.MonitorFaultHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/7.
 */
@Controller
@RequestMapping("/rds_monitorFaultHandle")
public class MonitorFaultHandleController {
    @Resource
    private MonitorFaultHandleService monitorFaultHandleService;


    @RequestMapping(value = "/getMonitorFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getMonitorFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer monitorMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = monitorFaultHandleService.getMonitorFaultHandle4DT(dtRequestDto,actorIds, orgId,monitorMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addMonitorMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addMonitorMaintenanceContent(Integer monitorFaultId, String monitorMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(monitorFaultHandleService.addMonitorMaintenanceContent(monitorFaultId, monitorMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishMonitorMaintenance")
    @ResponseBody
    public JsonMsgDto finishMonitorMaintenance(String monitorMaintenancePhoto,Integer monitorMaintainerId,String monitorMaintenanceTime,String monitorMaintenanceExplain,Integer monitorFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(monitorFaultHandleService.finishMonitorMaintenance(monitorMaintenancePhoto,monitorMaintainerId,monitorMaintenanceTime,monitorMaintenanceExplain,monitorFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/getMonitorFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getMonitorFaultHandleList4App(Integer orgId,Integer maintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(monitorFaultHandleService.getMonitorFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getMonitorReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getMonitorReceiptInfo4App(Integer monitorFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(monitorFaultHandleService.getMonitorReceiptInfo4App(monitorFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }
}
